/**
 * Created by Administrator on 14-2-10.
 */
var mongoose = require('mongoose');
var timestamps = require('mongoose-timestamp');//(给Model自动添加createdAt和updatedAt):

var Schema = mongoose.Schema,
    ObjectId = Schema.ObjectId;

// Schema 结构
var schema = new Schema({
    // _id:ObjectId,     // default id
    log_start:Date,      // 开始时间(每个小时一次统计)
    log_end:Date,        // 结束时间
    id_start:ObjectId,   // 开始id
    id_end:ObjectId,     // 结束id
    online_time_min:Number,  // 最小在线时间
    online_time_max:Number,  // 最大在线时间
    online_user_count:Number, // 活跃用户数
    count:Number            // 使用总次数
});
//Adding static methods to a Model
schema.statics.staticFunction = function(config, callback) {
    return this.find(config,function(error, items){
        console.log(items);
        callback(error, items);
    });
};
// built-in instance methods
schema.methods.instanceFunction = function(config, callback){
    this.model('MAPILogSummaryModel').find(config,function(error, items){
        console.log(items);
        callback(error, items);
    });

};
schema.plugin(timestamps);
mongoose.model('MAPILogSummaryModel', schema, 'MAPILogSummary');

